<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3">
            <?php echo $this->partial('_menu.phtml');?>
            <!--/.well -->
        </div>
        <div class="span9">
            <div class="wrap">
                <div id="main-content">
                    <?php
                    if($this->vente['p_ventes']) $action = $this->baseUrl() .'/admin/ventes/update-ventes';
                    else $action = $this->baseUrl() .'/admin/ventes/save-ventes';
                    ?>
                    <form class="form-horizontal" name="frm" action="<?php echo $action;?>" method="post" enctype="multipart/form-data">
                    <h3><?php echo $this->title ?></h3>
                    	<ul class="nav nav-tabs">
                    		<li class="frm1 active"><a href="#frm1">Généralités</a></li>
                    		<li class="frm2"><a href="#frm2">Description</a></li>
                    		<li class="frm3"><a href="#frm3">Couvertures</a></li>
                    		<li class="frm4"><a href="#frm4">Horaire</a></li>
                    		<li class="frm5"><a href="#frm5">Expo</a></li>
                    	</ul>
                    <div id="frm1">
                    <?php $date = new DateTime($this->vente['dtvente']); ?>
                    	<div class="control-group">
                    		<label class="control-label">Date :</label>
                    		<div class="controls">
                    			<input type="text" name="nom" id="datepicker" value="<?php echo $date->format('d/m/Y'); ?>"/>
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Titre :</label>
                    		<div class="controls">
                    			<input type="text" name="titre" value="<?php echo htmlspecialchars(stripslashes($this->vente['titre'])) ?>"/>
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Commission :</label>
                    		<div class="controls">
                    			<input type="text" name="com" style="width:25px" value="<?php echo stripslashes($this->vente['com']) ?>"/>%
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Type de vente :</label>
                    		<div class="controls">
                    			<input type="radio" name="type_vente" value="bd" checked <?php if($this->vente['type_vente'] == "bd") { echo "checked"; } ?>/> BD &nbsp;
                    			<input type="radio" name="type_vente" value="fg" <?php if($this->vente['type_vente'] == "fg") { echo "checked"; } ?>/> FG &nbsp;
                    			<input type="radio" name="type_vente" value="obj" <?php if($this->vente['type_vente'] == "obj") { echo "checked"; } ?>/> Objets
                    		</div>
                    	</div>
                    	<?php if($this->title == 'Editer'){ ?>
                    		<div class="control-group">
                    			<label class="control-label">Visible en ligne ?</label>
                    			<div class="controls">
                    				<input type="radio" class="radio" name="visible" value="1" <?php if($this->vente['visible']==1) echo 'checked="checked"' ?> name="visible"> Oui
                    				<input type="radio" class="radio" name="visible" value="0" <?php if($this->vente['visible']==0) echo 'checked="checked"' ?> name="visible"> Non
                    			</div>
                    		</div>
                    		<div class="control-group">
                    			<label class="control-label">Articles visibles en ligne ?</label>
                    			<div class="controls">
                    				<input class="radio" type="radio" value="1" name="articles" <?php if ($this->vente['articles_en_ligne'] == 1) { echo 'checked="checked"'; } ?>> Oui
                    				<input class="radio" type="radio" checked="checked" value="0" name="articles" <?php if ($this->vente['articles_en_ligne'] == 0) { echo 'checked="checked"'; } ?>> Non
                    			</div>
                    		</div>
                    	<?php } ?>
                    	<div class="control-group">
                    		<label class="control-label">Répertoires des photos :</label>
                    		<div class="controls">
                    			<input type="text" name="rep" value="<?php echo $this->vente['rep_photos'] ?>" />
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Nom du catalogue en PDF : </label>
                    		<div class="controls">
                    			<input type="text" name="pdf" value="<?php echo $this->vente['catalogue'] ?>" />
                    		</div>
                    	</div>
                    <?php if($this->title == 'Ajout') {?>
                    	<div class="control-group">
                    		<label class="control-label">Version papier dispo ?</label>
                    		<div class="controls">
                    			<input type="radio" name="cat_dispo" value="1" checked/> Oui &nbsp;
                    			<input type="radio" name="cat_dispo" value="0" /> Non
                    		</div>
                    	</div>
                    <?php }else{ ?>
                    	<div class="control-group">
                    		<label class="control-label">Catalogue papier dispo ?</label>
                    		<div class="controls">
                    			<input type="radio" name="cat_dispo" value="1" <?php if ($this->vente['cat_dispo'] == 1) { echo 'checked="checked"'; } ?>/> Oui &nbsp;
                    			<input type="radio" name="cat_dispo" value="0" <?php if ($this->vente['cat_dispo'] == 0) { echo 'checked="checked"'; } ?>/> Non
                    		</div>
                    	</div>
                    <?php } ?>
                    	<div class="control-group">
                    		<label class="control-label">Date limite ordre ?</label>
                    		<div class="controls">
                    			<input type="text" name="dtlimite" value="<?php echo stripslashes($this->vente['dtlimiteordre']) ?>" />
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Message si catalogue non dispo :</label>
                    		<div class="controls">
                    			<input type="text" name="msg_dispo_cat" value="<?php echo stripslashes($this->vente['msg_dispo_cat']) ?>" />
                    		</div>
                    	</div>
                    <?php if($this->title == 'Editer' ){ ?>
                    	<div class="control-group">
                    		<label class="control-label">PDF des résultats :</label>
                    		<div class="controls">
                    			<input type="text" name="resultats" value="<?php echo $this->vente['resultats'] ?>" />
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Autoriser renumérotation ?</label>
                    		<div class="controls">
                    			<input type="radio" name="renum" value="1" <?php if ($this->vente['renum'] == 1) { echo 'checked="checked"'; } ?> /> Oui
                    			<input type="radio" name="renum" value="0" <?php if ($this->vente['renum'] == 0) { echo 'checked="checked"'; } ?> /> Non
                    		</div>
                    	</div>
                    <?php } ?>
                    </div>
                    <div id="frm2" style="display:none;width:500px">
                    	<ul>
                    		<li style="display:block"><textarea name="contenu" cols="50" rows="15" name=""><?php echo stripslashes($this->vente['contenu']) ?></textarea>
                    			<script type="text/javascript">
                                CKEDITOR.replace( 'contenu', {});
                                </script>
                    		</li>
                    	</ul>
                    </div>
                    <div id="frm3" style="display:none">
                    	<div class="control-group">
                    		<label class="control-label">Couverture liste des ventes :</label>
                    		<div class="controls">
                    		  <?php if ($this->vente['vignette'] != "") { ?>
                              	<a href="../../cover/$this->vente['vignette']" target="_blank" ><?php echo $this->vente['vignette']?></a><br />
                                <p>Conserver cette vignette ? <input name="conserveVISmall" type="radio" value="1" checked /> Oui <input type="radio" name="conserveVISmall" value="<?php echo $this->vente['vignette'] ?>" /> Non</p>
                                <p>Si vous voulez remplacer la vignette, veuillez sélectionner un nouveau fichier :</p>
                              <?php
                                }
                              ?>
                    			<input type="file" name="userfileSmall" /> (petite image)
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Couverture détail vente :</label>
                    		<div class="controls">
                    		 <?php if ($row->vignette_vente != "") { ?>
                             	<a href="../../cover/$this->vente['vignette_vente']" target="_blank"><?php echo $this->vente['vignette_vente'] ?></a><br />";
                                <p>Conserver cette vignette ? <input name="conserveVIBig" type="radio" value="1" checked /> Oui <input type="radio" name="conserveVIBig" value="<?php echo $this->vente['vignette_vente'] ?>" /> Non</p>
                                <p>Si vous voulez remplacer la vignette, veuillez sélectionner un nouveau fichier :</p>
                       		 <?php
                             }
                             ?>
                    			<input type="file" name="userfileBig" />  (grande image)
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Auteur :</label>
                    		<div class="controls">
                    			<input type="text" name="auteur" value="<?php echo stripslashes($this->vente['auteur']) ?>" />
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Photographe :</label>
                    		<div class="controls">
                    			<input type="text" name="photographe" value="<?php echo stripslashes($this->vente['photographe']) ?>" />
                    		</div>
                    	</div>
                    </div>
                    <div id="frm4" style="display:none">
                    <?php if($this->title == 'Ajout'){ ?>
                    	<div class="control-group">
                    		<label class="control-label">Début 1ère tranche horaire :</label>
                    		<div class="controls">
                    			<input type="text" name="premier"  />
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Début 2nde tranche horaire :</label>
                    		<div class="controls">
                    			<input type="text" name="second"  />
                    		</div>
                    	</div>
                    	<div class="control-group">
                    		<label class="control-label">Début 3ème tranche horaire :</label>
                    		<div class="controls">
                    			<input type="text" name="troisieme"  />
                    		</div>
                    	</div>
                    <?php }else{
                     $ventesModel = new Admin_Model_Ventes();
                     $horaires = $ventesModel->getHoraires($this->vente['p_ventes']);
                     //print_r($horaires);
                    ?>
                    		<label class="control-label">Début 1ère tranche horaire :</label>
                    		<div class="controls">
                    		<input name="premier" type="text" value="<?php echo $this->vente['premier'] ?>" />
                    		</div>
                    		<div style="clear:both"> </div>
                    <?php foreach( $horaires as $pr) : ?>
                    		<label class="control-label"> &nbsp; </label>
                    		<div class="controls">
                    		<?php
                    		echo '<input type="checkbox" name="ckb1er[]" value="'. $pr['category_id'] .'"';
                    			$i = explode(",", $this->vente['cat_premier']);
                    			for ($compt=0; $compt<(count($i)); $compt++) {
                    				if ($pr['category_id'] == $i[$compt]) {
                    					echo " checked";
                    				}
                    			}
                    			echo "> " . sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ."<br>";
                    		?>
                    		</div>
                    		<div style="clear:both"> </div>
                    <?php endforeach ?>
                    		<label class="control-label">Début 2nde tranche horaire :</label>
                    		<div class="controls">
                    		<input name="premier" type="text" value="<?php echo $this->vente['second'] ?>" />
                    		</div>
                    		<div style="clear:both"> </div>
                    <?php foreach( $horaires as $pr) : ?>
                    		<label class="control-label"> &nbsp; </label>
                    		<div class="controls">
                    		<?php
                            echo '<input type="checkbox" name="ckb1er[]" value="'. $pr['category_id'] .'"';
                    			$i = explode(",", $this->vente['cat_premier']);
                    			for ($compt=0; $compt<(count($i)); $compt++) {
                    				if ($pr['category_id'] == $i[$compt]) {
                    					echo " checked";
                    				}
                    			}
                    			echo "> " . sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ."<br>";
                    		?>
                    		</div>
                    		<div style="clear:both"> </div>
                    <?php endforeach ?>
                    		<label class="control-label">Début 3ème tranche horaire :</label>
                    		<div class="controls">
                    		<input name="premier" type="text" value="<?php echo $this->vente['troisieme'] ?>" />
                    		</div>
                    		<div style="clear:both"> </div>
                    <?php foreach( $horaires as $pr) : ?>
                    		<label class="control-label"> &nbsp; </label>
                    		<div class="controls">
                    		<?php
                            echo '<input type="checkbox" name="ckb1er[]" value="'. $pr['category_id'] .'"';
                    			$i = explode(",", $this->vente['cat_premier']);
                    			for ($compt=0; $compt<(count($i)); $compt++) {
                    				if ($pr['category_id'] == $i[$compt]) {
                    					echo " checked";
                    				}
                    			}
                    			echo "> " . sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ."<br>";
                    		?>
                    		</div>
                    		<div style="clear:both"> </div>
                    <?php endforeach ?>
                    <?php } ?>
                    </div>
                    <div id="frm5" style="display:none;width:500px">
                    	<ul>
                    		<li style="display:block">
                    			<textarea name="resume" cols="50" rows="15"><?php echo stripslashes($this->vente['expo']) ?></textarea>
                    			 <script type="text/javascript">
                                CKEDITOR.replace( 'resume', {});
                                </script>
                    		</li>
                    	</ul>
                    </div>
                    <div align="center" style="width:400px">
                    	<a href="<?php echo $this->baseUrl() ?>/admin/index"><input class="btn btn-primary" type="button" name="cancel" value="annulé" /></a> &nbsp;
                    	<input class="btn btn-primary" type="submit" name="submit" value="sauver" />
                        <input type="hidden" name="p_ventes" value="<?php echo $this->vente['p_ventes']; ?>">
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
	$(document).ready(function(){
		$('.frm1').click(function(){
			$('#frm1').show();
			$('.frm1').addClass("active");
			$('#frm2').hide();
			$('.frm2').removeClass("active");
			$('#frm3').hide();
			$('.frm3').removeClass("active");
			$('#frm4').hide();
			$('.frm4').removeClass("active");
			$('#frm5').hide();
			$('.frm5').removeClass("active");
		});

		$('.frm2').click(function(){
			$('#frm2').show();
			$('.frm2').addClass("active");
			$('#frm1').hide();
			$('.frm1').removeClass("active");
			$('#frm3').hide();
			$('.frm3').removeClass("active");
			$('#frm4').hide();
			$('.frm4').removeClass("active");
			$('#frm5').hide();
			$('.frm5').removeClass("active");
		});

		$('.frm3').click(function(){
			$('#frm3').show();
			$('.frm3').addClass("active");
			$('#frm1').hide();
			$('.frm1').removeClass("active");
			$('#frm2').hide();
			$('.frm2').removeClass("active");
			$('#frm4').hide();
			$('.frm4').removeClass("active");
			$('#frm5').hide();
			$('.frm5').removeClass("active");
		});

		$('.frm4').click(function(){
			$('#frm4').show();
			$('.frm4').addClass("active");
			$('#frm1').hide();
			$('.frm1').removeClass("active");
			$('#frm2').hide();
			$('.frm2').removeClass("active");
			$('#frm3').hide();
			$('.frm3').removeClass("active");
			$('#frm5').hide();
			$('.frm5').removeClass("active");
		});

		$('.frm5').click(function(){
			$('#frm5').show();
			$('.frm5').addClass("active");
			$('#frm1').hide();
			$('.frm1').removeClass("active");
			$('#frm2').hide();
			$('.frm2').removeClass("active");
			$('#frm3').hide();
			$('.frm3').removeClass("active");
			$('#frm4').hide();
			$('.frm4').removeClass("active");
		});

			$( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );

	});
</script>
